package com.ljx.rag.rag.controller;

import com.ljx.rag.rag.domain.dto.OllamaMessage;
import com.ljx.rag.rag.domain.vo.req.ChatReq;
import com.ljx.rag.rag.domain.vo.req.ChatWithFileReq;
import com.ljx.rag.rag.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import java.util.Arrays;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2025-03-09  15:07
 */
@RestController
@RequestMapping("/chat")
public class ChatController {

    @Autowired
    private ChatService chatService;

    @PostMapping
    public Flux<String> chat(@RequestBody ChatReq req) {
        return chatService.chat(req);
    }

    @GetMapping
    public Flux<String> chat(@RequestParam("msg") String msg) {
        ChatReq req = new ChatReq(Arrays.asList(new OllamaMessage("user", msg)));
        return chatService.chat(req);
    }


    @GetMapping("/file")
    public Flux<String> chatWithFile(@RequestParam("msg") String msg) {
        ChatWithFileReq req = new ChatWithFileReq(msg);
        return chatService.chatWithFile(req);
    }




}
